<template>
  <div class="optimization">
    <!-- 导航栏 -->
    <van-nav-bar title="电视放肆购 再省一趴" left-arrow @click-left="back">
      <van-icon name="ellipsis" slot="right" />
    </van-nav-bar>
    <!-- 图 -->
    <van-image src="https://gfs10.gomein.net.cn/T1trLyBTZT1RCvBVdK.gif" />
    <!-- 优惠劵 -->
    <div class="coupon-box clearfix">
      <!-- 左侧优惠数 -->
      <strong class="coupon-price">
        <sup>￥</sup>
        <b>100</b>
      </strong>
      <!-- 中间满...可用 -->
      <div class="desc">
        <p class="coupon-desc" style="color:">满1680可用</p>
        <p class="gcc-desc" style="color:">自营彩电部分型号满1680使用</p>
        <i class="coupon-type" style="color:;border-color:">线上专享</i>
      </div>
      <!-- 点击领取 -->
      <div class="btn-box">
        <i class="btn">
          立即
          <br />领取
        </i>
      </div>
    </div>
    <!-- tab标签页 -->
    <van-tabs sticky v-model="catId">
      <van-tab v-for="(item,index) in catList" :key="index" :title="item.cat_name">
        <!-- 三星品牌日 start -->
        <!-- {{item.id}} -->
        <div class="brand">
          <van-image :src="item.cat_image" />
        </div>
        <!-- 三星品牌日 end -->
        <!-- 三星品牌日商品 -->
        <div class="brand-nav">
          <van-grid :column-num="2" :gutter="5">
            <van-grid-item v-for="(item,index) in goodsList" :key="index" @click="toGoodsDetail(item.id)">
              <div slot="icon">
                <van-image :src="item.image"></van-image>
              </div>
              <div slot="text" class="content">
                <div class="name" v-if="item.goods_name">
                  <span class="goods-tag">自营</span>
                  <span>{{item.goods_name}}</span>
                </div>
                <div class="subtitle">
                  <p>{{item.goods_desc}}</p>
                </div>
                <div class="price" v-if="item.price">
                  <strong>￥{{item.price}}</strong>
                </div>
              </div>
            </van-grid-item>
          </van-grid>
        </div>
        <!-- 三星品牌日商品 end -->

        <div class="tip-no-more">
          <i class="line" style="/* border-color: rgba(255, 255, 255, 0.9); */"></i>
          <i class="dot" style="background: rgba(255, 255, 255, 0.9);"></i>
          <span class="text" style="color: rgba(255, 255, 255, 0.9);">看完啦</span>
          <i class="dot" style="background: rgba(255, 255, 255, 0.9);"></i>
          <i class="line" style="border-color: rgba(255, 255, 255, 0.9);"></i>
        </div>
      </van-tab>
    </van-tabs>
    <!-- 底部 -->
    <footer class="common_footer">
      <div class="user_bar">
        <div class="left">
          <a class="a-fist">
            <span>{{mobile}}</span>
          </a>
          <p class="line"></p>
          <a>退出</a>
        </div>
        <div class="right">
          <p class="line"></p>
          <a href="//m.gome.com.cn/more.html">更多</a>
          <p class="line-two"></p>
          <a href="//m.gome.com.cn/feed_back.html">反馈</a>
        </div>
      </div>
      <div class="foot_msg">
        <div class="copyright">
          <p>copyright © 2000-2019 gome.com.cn</p>
          <p>
            客服热线：
            <a href="tel:4008-708-708">4008-708-708</a>
          </p>
        </div>
      </div>
    </footer>
  </div>
</template>

<script>
export default {
  data () {
    return {
      catList: [], // 分类
      goodsList: [],
      catId: 0,
      mobile: sessionStorage.getItem('mobile')
    }
  },
  methods: {
    //   返回上一级
    back () {
      this.$router.go(-1)// 返回上一层
    },
    getGoodsList (id) {
      // 商品
      this.$http.get(`/yx_goods/${id}`).then(res => {
        this.goodsList = res.data.data
      })
    },
    // 点击商品 跳转到商品详情
    toGoodsDetail (gid) {
      this.$router.push(`/goods_details`)
      localStorage.setItem('goodsID', gid)
    }
  },
  created () {
    // 先获取第一条数据
    this.$http.get(`/yx_goods/1`).then(res => {
      this.goodsList = res.data.data
    })
    // 商品分类
    this.$http.get('/yx_goods_categories').then(res => {
      this.catList = res.data.data
    })
  },
  // 监听
  watch: {
    catId () {
      this.getGoodsList(this.catId + 1)
    }
  }
}
</script>

<style lang="less">
.clearfix:after {
  content: "";
  display: block;
  clear: both;
}

.optimization {
  background-color: rgb(153, 16, 57);

  .van-nav-bar .van-icon {
    color: #969799;
    font-size: 1.4rem;
    cursor: pointer;
  }
  .coupon-box {
    position: relative;
    width: 96%;
    height: 5rem;
    margin: 0.28rem auto;
    border-radius: 0.3rem;
    background-color: white;
    flex: 1;
    box-sizing: border-box;
    overflow: hidden;
  }

  .coupon-price {
    float: left;
    display: block;
    height: 100%;
    width: 30%;
    color: #f20c59;
    font-size: 0.8rem;
    position: relative;
    text-align: center;
  }

  .coupon-price sup {
    position: relative;
    bottom: 0.9rem;
    font-weight: 700;
  }

  .coupon-price b {
    margin: 0;
    line-height: 4.5rem;
    font-size: 1.8rem;
    font-weight: 700;
  }

  .desc {
    float: left;
    height: 100%;
    width: 50%;
    margin-left: -0.2rem;
  }

  .desc .coupon-desc {
    font-size: 0.96rem;
    margin-top: 0.63rem;
    font-weight: 700;
    color: #262c32;
  }

  .desc .gcc-desc {
    font-size: 0.71rem;
    color: #919599;
    margin-top: 0.15rem;
  }

  .desc .coupon-type {
    font-size: 0.6rem;
    border: 0.05rem solid #f20c59;
    border-radius: 0.45rem;
    color: #f20c59;
    display: inline-block;
    padding: 0.01rem 0.3rem;
    margin-top: 0.09rem;
  }

  .btn-box {
    float: right;
    width: 20%;
    height: 100%;
    margin-right: 0;
  }

  .btn-box .btn {
    width: 100%;
    height: 100%;
    margin-top: 0;
    background-size: 100% 100%;
    background: url("../assets/image/wxy-image/btn-img.png") no-repeat;
    display: block;
    background-size: 5rem 4.99rem;
    color: #fff;
    font-size: 0.8rem;
    text-align: center;
    padding-top: 1.5rem;
  }

  // .van-image {
  //   margin-top: 8px;
  // }

  // .brand-nav {
  //   margin-top: -4px;
  // }

  // .van-grid:first-child {
  //   background-color: rgb(0, 53, 103);
  //   padding-bottom: 5px;
  // }

  .content .name {
    color: #333;
    font-size: 0.8rem;
    margin-top: 0.14rem;

    .goods-tag {
      background-color: #f20d5b;
      color: #fff;
      font-size: 0.4rem;
      border-radius: 0.1rem;
      padding: 0 0.11rem;
      border: none;
      margin-right: 0.4rem;
    }
  }

  .content .subtitle {
    font-size: 0.7rem;
    color: #f20c59;
  }

  .content .price {
    color: #f20c59;
    margin-top: 0.3rem;
  }

  .tip-no-more {
    display: -webkit-box;
    display: box;
    display: -ms-flexbox;
    display: flex;
    box-align: center;
    align-items: center;
    line-height: 1.3rem;
    height: 3.9rem;
    font-size: 0.82rem;
    color: #666;
    width: 50%;
    margin: 0 auto;
  }

  .tip-no-more .line {
    display: block;
    -ms-flex: 1;
    flex: 1;
    box-sizing: border-box;
    border-bottom: 1px solid #e6e6e6;
    height: 0.01rem;
  }

  .tip-no-more .dot {
    display: block;
    width: 0.28rem;
    height: 0.28rem;
    background-color: #e6e6e6;
    border-radius: 99rem;
  }

  .tip-no-more .text {
    width: 3.3rem;
    text-align: center;
    margin: 0 0.1rem;
  }

  .tip-no-more .dot {
    display: block;
    width: 0.28rem;
    height: 0.28rem;
    background-color: #e6e6e6;
    border-radius: 99rem;
  }

  .tip-no-more .line {
    display: block;
    flex: 1;
    box-sizing: border-box;
    border-bottom: 1px solid #e6e6e6;
    height: 0.01rem;
  }

  .common_footer {
    background: #fff;

    .user_bar {
      padding-left: 1.6rem;
      padding-right: 1.6rem;
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      border-top: 1px solid #ddd;
      border-bottom: 1px solid #ddd;
      // overflow: hidden;
      height: 1.98rem;
      line-height: 1.98rem;
      font-size: 0.8rem;

      .left {
        position: relative;
        height: 1.98rem;
        line-height: 1.98rem;
        display: block;
        flex: 1;
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        box-sizing: border-box;

        .line {
          position: absolute;
          width: 1px;
          height: 1.26rem;
          background-color: #ddd;
          top: 0.36rem;
          left: 50%;
        }
      }

      a {
        color: #888;
        font-size: 0.8rem;
        display: block;
        flex: 2;
        text-align: center;
      }

      .right {
        position: relative;
        height: 1.98rem;
        line-height: 1.98rem;
        display: block;
        flex: 1;
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
        box-sizing: border-box;

        .line {
          position: absolute;
          width: 1px;
          height: 1.26rem;
          background-color: #ddd;
          top: 0.36rem;
          left: 0;
        }

        .line-two {
          position: absolute;
          width: 1px;
          height: 1.26rem;
          background-color: #ddd;
          top: 0.36rem;
          left: 50%;
        }
      }
    }

    .user_bar .left a.a-fist span {
      display: inline-block;
      white-space: nowrap;
      width: 3.6rem;
      overflow: hidden;
      text-overflow: ellipsis;
      text-align: center;
      height: 1.98rem;
    }

    .foot_msg {
      width: 80%;
      margin: auto;
      padding-top: 1.5rem;
      text-align: center;

      .copyright {
        padding-bottom: 1.3rem;

        p {
          line-height: 1.36rem;
          text-align: center;
          font-size: 0.66rem;
          color: #888;

          a {
            color: #888;
          }
        }
      }
    }
  }
}
</style>
